package cn.bdqn.service.impl;


import cn.bdqn.domain.Overview;
import cn.bdqn.mapper.OverviewMapper;
import cn.bdqn.service.OverviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 概述业务实现类
 * @author dkj
 */
@Service("overviewService")
public class OverviewServiceImpl implements OverviewService {


    @Autowired
    private OverviewMapper overviewMapper;
    /**
     * 保存 不发布
     * @param overview
     */
    @Override
    public void saveOverview(Overview overview) {

        //更新概述对象 不发布
        overviewMapper.updateByPrimaryKey(overview);
    }

    /**
     * 发布
     * @param overview
     */
    @Override
    public void releaseOverview(Overview overview) {

        //修改发布状态
        overview.setReleaseState(0);
        //前端展示的概述更新为最新的数据
        overview.setShowSummary(overview.getEditSummary());
        //更新
        overviewMapper.updateByPrimaryKey(overview);
    }

    /**
     * 根据基地id和描述状态查询对象
     * @param baseId
     * @param descriptionType
     * @return
     */
    @Override
    public Overview queryByBaseIdAndDescriptionType(Integer baseId, Integer descriptionType) {
        //查询
        return overviewMapper.selectByBaseIdAndDescriptionType(baseId,descriptionType);
    }
}
